package geektime.spring.springbucks.repository;


import geektime.spring.springbucks.model.Coffee;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
import java.util.Map;

public interface CoffeeRepository  {

    @Insert("insert into t_coffee (name, price, create_time, update_time)"
            + "values (#{name}, #{price}, now(), now())")
    @Options(useGeneratedKeys = true)
    int save(Coffee coffee);


    @Select("select count(*) from t_coffee")
    long count();

    @Select("select * from t_coffee where name=#{name}")
    List<Coffee> findByName(String name);

    @Delete("delete from t_coffee where id=#{id}")
    int deleteById(Long id);

    @Select("select * from t_coffee order by id")
    List<Coffee> findAllByPage(RowBounds rowBounds);

    @Select("select * from t_coffee order by id")
    List<Coffee> findAll();

    List<Coffee> findAllByIds(@Param("ids") List<Long> ids);

    int updateByPrimaryKeySelective(Coffee coffee);

}
